FROM swr.cn-north-4.myhuaweicloud.com/ooops/golang:1.18.10 as builder

WORKDIR /app

COPY . .

ENV GOPROXY https://goproxy.cn

RUN CGO_ENABLED=0 GOOS=linux go build -o opsagent main.go

FROM swr.cn-north-4.myhuaweicloud.com/ooops/alpine:3.20

RUN apk add --no-cache tzdata bash curl && \
    cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
    echo "Asia/Shanghai" > /etc/timezone

WORKDIR /app

COPY --from=builder /app/opsagent /app/config.yaml .

CMD ["./opsagent"]